package edu.yourl.persistence;

import org.springmodules.db4o.ObjectServerFactoryBean;

import com.db4o.Db4o;
import com.db4o.User;
import com.db4o.config.Configuration;

import edu.yourl.domain.Gossip;
import edu.yourl.domain.Url;

public class YourlObjectServerFactoryBean extends ObjectServerFactoryBean {

	@Override
	public void afterPropertiesSet() throws Exception {
		this.setConfiguration(buildConfiguration());
		super.afterPropertiesSet();
	}

	private Configuration buildConfiguration() {
		Configuration configuration = Db4o.newConfiguration();
		configuration.updateDepth(5);
		configuration.activationDepth(5);
		configuration.objectClass(User.class).cascadeOnActivate(true);
		configuration.objectClass(User.class).cascadeOnUpdate(true);
		configuration.objectClass(Gossip.class).cascadeOnActivate(true);
		configuration.objectClass(Gossip.class).cascadeOnUpdate(true);
		configuration.objectClass(Url.class).cascadeOnActivate(true);
		configuration.objectClass(Url.class).cascadeOnUpdate(true);
		return configuration;
	}
	
}
